package com.kehao.leetcode.jzoffer;

import org.junit.Test;

import java.util.Arrays;

/**
 * @author Kehao.Chen
 * @version 1.0
 * @date 2022/6/29 10:12
 */
public class JZSolution038  {
    public int[] dailyTemperatures(int[] temperatures) {
        int[] result = new int[temperatures.length];
        for (int i = 0; i < result.length; i++) {
            for (int j = i+1; j < temperatures.length; j++) {
                if(temperatures[j]>temperatures[i]){
                    result[i] = j-i;
                    break;
                }
            }
        }
        return result;
    }

    @Test
    public void tesst01(){
        int[] temperatures = {73,74,75,71,69,72,76,73};
        int[] result = dailyTemperatures(temperatures);
        Arrays.stream(result).forEach(i-> System.out.print(i+" "));
    }

    @Test
    public void tesst02(){
        int[] temperatures = {30,40,50,60};
        int[] result = dailyTemperatures(temperatures);
        Arrays.stream(result).forEach(i-> System.out.print(i+" "));
    }
}
